<!DOCTYPE html>

<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 70%; width: 70% }
    </style>
	<script type="text/javascript" src="js/jquery.min.js">
	</script>
	<script type="text/javascript">
	
	(function($) {
		$.fn.setReadonly = function(readonly) {
			return this.filter("input:text").css('opacity', readonly ? 0.5 : 1).attr('readonly', readonly).end();
		};
	})(jQuery);
	
	$(function(){
	
		$('input').removeAttr('disabled');
		
		$('#sameAddress').click(function(event) {
			var same = this.checked;
			$('#billAddress').val(same ? $('#shipAddress').val() : '');
			$('#billCity').val(same ? $('#shipCity').val() : '');
			$('#billState').val(same ? $('#shipState').val() : '');
			
			$('#billingAddress input').setReadonly(same);
		});
		
		//alert($('#billingAddress').text());
		
		//$('#billingAddress input').each(function(){
		//	alert(this.id);
		//});
		
	});
	</script>
  </head>
  <body>
    
	<div>
		<table id="shippingAddress">
		<tr>
			<td>
				Address
			</td>
			<td>
				<input id="shipAddress" type="text"  disabled/>
			</td>
		</tr>
		<tr>
			<td>
				City
			</td>
			<td>
				<input id="shipCity" type="text"  />
			</td>
		</tr>
		<tr>
			<td>
				State
			</td>
			<td>
				<input id="shipState" type="text"  />
			</td>
		</tr>
	</div>
	
	<div>
		<table id="billingAddress">
		<tbody>
		<tr>
			<td>
				Same address
			</td>
			<td>
				<input type="checkbox" id="sameAddress" />
			</td>
		</tr>
		<tr>
			<td>
				Address
			</td>
			<td>
				<input id="billAddress" type="text" />
			</td>
		</tr>
		<tr>
			<td>
				City
			</td>
			<td>
				<input id="billCity" type="text" />
			</td>
		</tr>
		<tr>
			<td>
				State
			</td>
			<td>
				<input id="billState" type="text"  />
			</td>
		</tr>
		</tbody>
	</div>
  </body>
</html>